// pages/mine/mywish/mywish.js

import Toast from '../../../miniprogram_npm/@vant/weapp/toast/toast';
import {
    GetStudentgrades, // 我的成绩查询
    GetHewillMyzylist, // 我的志愿表
} from '../../../api/index'

Page({

  /**
   * 页面的初始数据
   */
  data: {
        listArray:[],
        title:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    
  },

  // 列表点击事件
  cellSelectAction(event) {
      console.log(event)
     wx.navigateTo({
       url: '/pages/index/currentdesire/currentdesire?type=' + event.currentTarget.dataset.type,
     })
  },

  // 去填报
  submitAction() {
      wx.navigateTo({
        url: '/pages/index/intelligentfilling/intelligentfilling',
      })
  },

  _GetHewillMyzylist(data, isLoading) {
    GetHewillMyzylist(data, isLoading).then(res => {
        console.log(res)
        let that = this;
        let code = res.code;
        // Toast('成功')
        if (code == 200) {
            let array = res.rows;
            this.setData({
                listArray:array
            })
        } else {
            Toast(res.msg)
        }
    })
},

// 我的成绩查询
_GetStudentgrades(data, isLoading) {
    GetStudentgrades(data, isLoading).then(res => {
        console.log(res)
        let code = res.code;
        // Toast('成功')
        if (code == 200) {
            let array = res.rows;
            let title = '黑龙江 · '
            let mutableArray = [];
            if (array.length != 0) {
                let model = array[0]
                if (model.isWuli == 1) {
                    title += "物 | "
                    // mutableArray.push('物理')
                } else {
                    title += "历 | "
                    // mutableArray.push('历史')
                }
                if (model.isHuaxue == 1) {
                    title += "化"
                    // mutableArray.push('化学')
                }
                if (model.isShengwu == 1) {
                    title += "生"
                    // mutableArray.push('生物')
                }
                if (model.isZhengzhi == 1) {
                    title += "政"
                    // mutableArray.push('政治')
                }
                if (model.isDili == 1) {
                    title += "地"
                    // mutableArray.push('地理')
                }
                let str = mutableArray.join(' / '); // 使用逗号分隔
                let content = title + str + '  ' + model.myScore + '分 ' + model.myWeici + '名'
                console.log(content)
                this.setData({
                    title:content
                })
            }
        } else {
            // Toast(res.msg)
        }
    })
},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    let openid = wx.getStorageSync('openId') || '';
    this._GetStudentgrades('?openId=' + openid, false)
    this._GetHewillMyzylist('?openId=' + openid, true)
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  onShareTimeline: function (){

},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})